package com.kaifamiao.month04.day25;

import java.time.*;
import java.util.Date;

public class Demo {

    public static void main(String[] args) {
//        Date date = new Date();
//        System.out.println(date.getMonth()); // 获取月份
//        System.out.println(date.getDate()); // 第几天
//        System.out.println(date.getDay()); // 一周中的第几天
//        System.out.println(date.getHours()); // 小时
//        Date date1 = new Date(365L * 24 * 60 * 60 * 1000);
//        Date date2 = new Date(2022, 3, 25);
//        System.out.println(date2);
//        System.out.println(date1);
//        System.out.println(date.after(date1)); // date 是否在 date1 之后
//        System.out.println((long)date.getTimezoneOffset());
//        System.out.println(Date.parse("7/20/22"));
//        Calendar c = Calendar.getInstance();
//        c.set(2022,3,4);
//        System.out.println(c.get(Calendar.YEAR));
//        LocalDate ld = LocalDate.now();
//        System.out.println(ld);
        final long ms = 1000L * 60 * 60 * 24 * 365 * 26;
        Date date = new Date(ms);
        System.out.println(date);//Tue Dec 26 08:00:00 CST 1995

        System.out.println("===============");
        //Instant指在时间线上的瞬间点
        Instant instant = date.toInstant(); // Date ==> java.time.Instant
        //ZoneId指一个时区ID
        ZoneId zone = ZoneId.systemDefault();//时区设置成亚洲/上海时间
        //ZonedDateTime指具有时区的日期时间
        ZonedDateTime zonedDateTime = instant.atZone(zone);

        LocalDateTime datetime = zonedDateTime.toLocalDateTime();
        System.out.println(datetime);//1995-12-26T08:00

        LocalDate d = zonedDateTime.toLocalDate();
        System.out.println(d);//1995-12-26
        LocalTime t = zonedDateTime.toLocalTime();
        System.out.println(t);//08:0x8000



    }
}
